import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;


public class GUI implements MouseListener, KeyListener
{
	protected MaiDrawu GraphicPanel;
	protected JFrame MaiFramu;
	protected World w;
	protected Player p;
	public GUI(World w, Player p)
	{
		this.w = w;
		this.p = p;
		MaiFramu = new JFrame();
		GraphicPanel = new MaiDrawu(w,p);
		MaiFramu.addMouseListener(this);
		MaiFramu.addKeyListener(this);
		MaiFramu.add(GraphicPanel);
		MaiFramu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		MaiFramu.setSize(806,632);
		MaiFramu.setLocation(300, 0);
		MaiFramu.setVisible(true);
		MaiFramu.setResizable(false);
	}
	protected void render()
	{
//		if(MaiFramu.getX()!=200 || MaiFramu.getX()!=0) 
//		MaiFramu.setLocation(200, 0);
		try{Thread.sleep(1);}catch(Exception e) {}
		MaiFramu.repaint();
	}
	@Override
	public void keyPressed(KeyEvent kE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void keyReleased(KeyEvent kE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void keyTyped(KeyEvent kE) {
		char pressed = kE.getKeyChar();
		switch (pressed)
		{
//<<<<<<< .mine
		case 'a': p.left = true; p.accelerate(-.5,0);break;
		case 'd': p.left = false; p.accelerate(.5,0);break;
//=======
//		case 'd': p.left = false; p.accelerate(.5,0);break;
//		case 'a': p.left = true; p.accelerate(-.5,0);break;
//>>>>>>> .r9
		default: break;
		}
	}
	@Override
	public void mouseClicked(MouseEvent mE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseEntered(MouseEvent mE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseExited(MouseEvent mE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mousePressed(MouseEvent mE) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void mouseReleased(MouseEvent mE) {
		// TODO Auto-generated method stub
		
	}
}
